package com.len.controller;

import com.len.util.JsonUtil;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 控制器异常全局处理器
 */
@ControllerAdvice
public class GlobalController {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public JsonUtil handleException(Exception e){
        return JsonUtil.error(e.getMessage());
    }
}
